#include "Token.h"
#include "../Symboltable/Information.h"
#include "InformationInteger.h"

Token::Token(TokenType newType, size_t newLine, size_t newColumn,
		SharedPointer<IInformation> newInfo) :
		type(newType), line(newLine), column(newColumn), information(newInfo) {
}

void Token::cleanUp() {
	// SharedPointer handles clean up already...
}

void Token::setInformation(const SharedPointer<IInformation> newInformation) {
	information = newInformation;
}

IInformation* Token::getInformation() {
	return NULL;
}

void Token::setType(const TokenType newType) {
	type = newType;
}

TokenType Token::getType() {
	return type;
}

void Token::setLine(const size_t newLine) {
	line = newLine;
}

size_t Token::getLine() {
	return line;
}

void Token::setColumn(const size_t newColumn) {
	column = newColumn;
}

size_t Token::getColumn() {
	return column;
}

char* Token::getLexem() {
	TokenType t = information->getType();
	if (t == IDENTIFIER || t == RESERVED_WORD) {
		return ((Information*)&*information)->getLexem();
	}
	return NULL;
}

int Token::getValue() {
	TokenType t = information->getType();
	if (t == INTEGER) {
		return ((InformationInteger*)&*information)->getNumber();
	}
	return 0;
}
